<?php
/**
 * Created by PhpStorm.
 * User: jocky
 * Date: 2018/1/31
 * Time: 10:29
 */

/**
 * @var int $uid
 * @var string $accountType
 * @var array $fields
 * @var $record \common\models\ar\RealName
 */
$str = "";
foreach ($fields as $v) {
    if ($v['is_must']) {
        $v['key'] = ' * ' . $v['key'];
    }


    $str .= <<<EOF
<div class='form-group'>
    <label class="control-label col-md-3 col-sm-3 col-xs-12">{$v["key"]}</label>
    <div class="col-md-7 col-sm-7 col-xs-12">
EOF;

    switch ($v['type']) {
        case 1://填空
            $str .= "<input type='text' class='form-control' value='" . $v['field_value'] . "'>";
            break;
        case 3://单选
        case 7://选择框
            $fieldTemplates = explode('|', $v['val']);//字段模板
            $selected = $v['field_value'] ? $v['field_value'] : 0;

            foreach ($fieldTemplates as $value) {
                $tmp = explode('=>', $value);
                if ($selected == $tmp[0]) {
                    $str .= "<input type='text' class='form-control' value='" . $tmp[1] . "'>";
                }
            }
            break;
        case 5://图片
            $str .= "<img src='" . $v['field_value'] . "' class='img-responsive img-thumbnail'/>";
            break;
        default:
            break;
    }
    $str .= "</div></div>";
}
?>
<div class="row">
    <div class="col-md-12">
        <form class="form-horizontal form-label-left" style="max-height: 480px;overflow-y: scroll;" id="from1">
            <?= $str; ?>
        </form>

        <hr/>
        <form class="form-horizontal form-label-left">
            <div class="form-group">
                <label class="control-label col-md-3 col-sm-3 col-xs-12">拒绝原因：</label>
                <div class="col-md-7 col-sm-7 col-xs-12">
                    <textarea class="form-control"
                              rows="3"
                              id="realNameCheckErrorMsg"
                              placeholder="执行拒绝操作时为必填项，客户端会显示拒绝的原因"><?= $record->update_error_msg; ?></textarea>
                </div>
            </div>
            <?php if ($record->update_status == 1) { ?>
                <div class="form-group">
                    <label class="control-label col-md-3 col-sm-3 col-xs-12"></label>
                    <div class="col-md-7 col-sm-7 col-xs-12">
                        <button type="button" class="btn btn-sm btn-danger"
                                onclick="realNameCheckObj.operates(<?= $uid; ?>,0)">
                            拒 绝
                        </button>
                        <button type="button" class="btn btn-sm btn-success"
                                onclick="realNameCheckObj.operates(<?= $uid; ?>,1)">
                            通 过
                        </button>
                        <button type="button" class="btn btn-sm btn-danger" style="background: #cd5c5c"
                                onclick="realNameCheckObj.operates(<?= $uid; ?>,9)">
                            永久性拒绝
                        </button>
                    </div>
                </div>
            <?php } ?>
        </form>
    </div>
</div>